package org.csu.gp_store.bo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import org.csu.gp_store.entity.FacBusiness;
import org.csu.gp_store.entity.Factory;
import org.csu.gp_store.entity.Product;

@Data
public class FactoryBO {
    private Long factoryID;
    private Long companyID;
    private String factoryName;
    private String address;
    private int status;
    private Long productID;
    private int productStatus;
    private Long categoryID;
    private String productName;
    private String description;
    private String firstImg;

    public static FactoryBO toFactoryBO(Factory factory, Product product){
        FactoryBO factoryBO = new FactoryBO();
        factoryBO.setFactoryID(factory.getFactoryID());
        factoryBO.setFactoryName(factory.getFactoryName());
        factoryBO.setAddress(factory.getAddress());
        factoryBO.setCompanyID(factory.getCompanyID());
        factoryBO.setStatus(factory.getStatus());
        factoryBO.setProductStatus(product.getStatus());
        factoryBO.setProductID(product.getProductID());
        factoryBO.setDescription(product.getDescription());
        factoryBO.setProductName(product.getProductName());
        factoryBO.setCategoryID(product.getCategoryID());
        return factoryBO;
    }

    public static FactoryBO toFactoryBO(Factory factory, FacBusiness facBusiness){
        FactoryBO factoryBO = new FactoryBO();
        factoryBO.setFactoryID(factory.getFactoryID());
        factoryBO.setFactoryName(factory.getFactoryName());
        factoryBO.setAddress(factory.getAddress());
        factoryBO.setCompanyID(factory.getCompanyID());
        factoryBO.setStatus(factory.getStatus());
        factoryBO.setProductStatus(facBusiness.getStatus());
        factoryBO.setProductID(facBusiness.getProductID());
        return factoryBO;
    }

    public static FactoryBO toFactoryBO(Factory factory, ProductBO product){
        FactoryBO factoryBO = new FactoryBO();
        factoryBO.setFactoryID(factory.getFactoryID());
        factoryBO.setFactoryName(factory.getFactoryName());
        factoryBO.setAddress(factory.getAddress());
        factoryBO.setCompanyID(factory.getCompanyID());
        factoryBO.setStatus(factory.getStatus());
        factoryBO.setProductStatus(product.getStatus());
        factoryBO.setProductID(Long.valueOf(product.getProductID()));
        factoryBO.setDescription(product.getDescription());
        factoryBO.setProductName(product.getProductName());
        factoryBO.setCategoryID(Long.valueOf(product.getCategoryID()));
        factoryBO.setFirstImg(product.getImage());
        return factoryBO;
    }

    public static Factory toFactory(FactoryBO factoryBO){
        Factory factory = new Factory();
        factory.setFactoryID(factoryBO.getFactoryID());
        factory.setFactoryName(factoryBO.getFactoryName());
        factory.setCompanyID(factoryBO.getCompanyID());
        factory.setStatus(factoryBO.getStatus());
        factory.setAddress(factoryBO.getAddress());
        return factory;
    }

    public static FacBusiness toFacBusiness(FactoryBO factoryBO){
        FacBusiness facBusiness = new FacBusiness();
        facBusiness.setFactoryID(factoryBO.getFactoryID());
        facBusiness.setStatus(factoryBO.getProductStatus());
        facBusiness.setProductID(factoryBO.getProductID());
        return facBusiness;
    }

    public static Product toProduct(FactoryBO factoryBO){
        Product product = new Product();
        product.setProductID(factoryBO.getProductID());
        product.setProductName(factoryBO.getProductName());
        product.setStatus(factoryBO.getProductStatus());
        product.setCompanyID(factoryBO.getCompanyID());
        product.setDescription(factoryBO.getDescription());
        product.setCategoryID(factoryBO.getCategoryID());
        return product;
    }
}
